﻿package com.tudou.home.controller
{
    import com.tudou.ad.consts.*;
    import com.tudou.home.commands.*;
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.model.*;
    import com.tudou.home.track.*;
    import com.tudou.home.view.*;
    import com.tudou.track.*;
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class PlayListCommand extends SimpleCommand implements ICommand
    {

        public function PlayListCommand()
        {
            return;
        }// end function

        override public function execute(param1:INotification) : void
        {
            var _loc_4:SkinMediator = null;
            var _loc_6:PageInfo = null;
            var _loc_7:Boolean = false;
            var _loc_8:Boolean = false;
            var _loc_9:int = 0;
            var _loc_2:* = facade.retrieveProxy(PlayListProxy.NAME) as PlayListProxy;
            var _loc_3:* = facade.retrieveProxy(PlayerProxy.NAME) as PlayerProxy;
            _loc_4 = facade.retrieveMediator(SkinMediator.NAME) as SkinMediator;
            var _loc_5:* = facade.retrieveProxy(PageProxy.NAME) as PageProxy;
            _loc_6 = PageInfo.getInstance();
            switch(param1.getName())
            {
                case PlayListCommandSet.PLAY_LIST_LOADED:
                {
                    _loc_4.setPlayList(_loc_2.getPlayList());
                    _loc_4.setIndex(_loc_2.getIndex());
                    break;
                }
                case PlayListCommandSet.CHANGE_ITEM:
                {
                    _loc_7 = _loc_4.isFullScreen;
                    _loc_8 = AdConsts.FRONT_AD_ING;
                    _loc_9 = _loc_6.iid;
                    _loc_4.complete();
                    _loc_4.setIndex(_loc_2.getIndex());
                    sendNotification(AdCommandSet.CLEAR_ALL);
                    PlayTimeTracker.getInst().stop();
                    if (_loc_7)
                    {
                        PlayerEventTracker.getInstance().sendChangeItemTrack(_loc_8);
                        _loc_6.reset();
                        _loc_5.startPlayVideo(_loc_9, false);
                        sendNotification(ExternalCommandSet.BOOT);
                    }
                    else
                    {
                        _loc_3.close();
                        _loc_5.startPlayVideo(_loc_9, true);
                    }
                    break;
                }
                case PlayListCommandSet.NEXT_ITEM:
                {
                    _loc_2.nextItem();
                    break;
                }
                case PlayListCommandSet.PREV_ITEM:
                {
                    _loc_2.prevItem();
                    break;
                }
                case PlayListCommandSet.THIS_INDEX:
                {
                    _loc_6.changeItemManual = true;
                    _loc_2.thisIndex(param1.getBody() as uint);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
